package cn.admin.remoting.locale;

import java.text.MessageFormat;
import java.util.ListResourceBundle;
import java.util.ResourceBundle;

public class LogResources extends ListResourceBundle {
    private static final ResourceBundle logBundle = ResourceBundle.getBundle(LogResources.class.getName());
    public static final String CONNECT_FAIL = "connectFail";
    public static final String CONNECT_CANCEL = "connectCancelled";
    public static final String GET_CONNECT_FAIL = "getConnectFail";
    public static final String INIT_CLOSE_CONNECTION = "initCloseConnection";
    public static final String NON_INIT_CLOSE_CONNECTION = "nonInitCloseConnection";
    public static final String REQUEST_SEND_FAIL = "requestSendFail";
    public static final String RESP_TIMEOUT = "respTimeout";
    public static final String RESP_LOST_BY_CLOSED = "respLostBecauseConnectionClosed";
    public static final String CONNECTION_RESP_TIMEOUT = "connectionRespTimeout";
    public static final String CONNECTION_RESP_ERROR = "connectionRespError";
    public static final String CONNECTION_RESP_ERROR_STACK = "connectionRespErrorWithStack";
    public static final String CONNECTION_WRITE_TIMEOUT = "connectionWriteTimeoutException";
    public static final String CONNECTION_EXCEPTION = "connectionException";
    public static final String NO_RESP_RECEIVER = "noResponseReceiver";
    public static final String INVALID_SERIALIZE = "invalidSerializeType";
    public static final String INVALID_CONNECTION_GROUPING = "invalidConnectionGrouping";
    public static final String MAX_READ_IDLE_CLIENT = "clientExceedsMaxReadIdle";
    public static final String MAX_READ_IDLE_SERVER = "serverExceedsMaxReadIdle";
    public static final String IO_THREAD_CANNOT_CALLBACK = "ioThreadCannotCallback";
    public static final String IO_THREAD_CANNOT_DO_REQUEST = "ioThreadCannotDoRequest";
    public static final String REQUEST_PROCESSOR_NOT_FOUND = "requestProcessorNotFound";
    public static final String SERVER_START_SUCCESS = "serverStartSuccess";
    public static final String SERVER_START_FAIL = "serverStartFail";
    public static final String SERVER_STOP_SUCCESS = "serverStopSuccess";
    public static final String SERVER_EMPTY_GROUP = "server_group_empty";
    public static final String RECONNECT_THREAD_RUN = "reconnectThreadStart";
    public static final String RECONNECT_THREAD_EXIT = "reconnectThreadExit";
    public static final String RECONNECT_NEW_TASK = "reconnectNewTask";
    public static final String RECONNECT_TASK_RETRY = "reconnectTaskRetry";
    public static final String RECONNECT_TASK_SUCCESS = "reconnectTaskSuccess";
    public static final String RECONNECT_TASK_CANCELLED = "reconnectTaskCancelled";
    public static final String TIMEOUTSCAN_SLEEP_TOO_LONG = "timeoutScanSleepTooLong";
    public static final String DUPLICATE_MSG_ID = "duplicateMsgId";
    public static final String INCORRECT_IMPL_REQUESTPROCESSOR = "incorrectImplRequestProcessor";
    public static final String INCORRECT_IMPL_RESPONSECALLBACK = "incorrectImplResponseCallback";
    private static final Object[][] contents = new Object[][]{{"connectFail", "连接创建失败[{0}]."}, {"connectCancelled", "连接创建操作被取消[{0}]."}, {"getConnectFail", "获取连接失败[{0}]."}, {"initCloseConnection", "########## [init-close] 主动关闭连接[{0}]，原因:{1}"}, {"nonInitCloseConnection", "########## [non-init-close] 被动关闭连接[{0}]"}, {"requestSendFail", "请求发送失败，失败原因[{0}], {1}."}, {"respTimeout", "响应超时."}, {"respLostBecauseConnectionClosed", "由于连接关闭, 导致请求的响应丢失."}, {"connectionRespTimeout", "等待响应超时, 等待时间=[{0}]ms."}, {"connectionRespError", "异常响应[{0}], {1}.\n业务请求: [{2}].\n原因: {3}"}, {"connectionRespErrorWithStack", "异常响应[{0}], {1}.\n业务请求: [{2}].\n原因: {3}\n异常堆栈:\n[{4}]."}, {"connectionWriteTimeoutException", "########## 出现写超时错误, 关闭连接[{0}]."}, {"connectionException", "连接[{0}]上出现错误[{1}]."}, {"noResponseReceiver", "未找到响应requestId=[{0}]的消息接收者, 响应来自[{1}], 业务响应类型[{2}]."}, {"invalidSerializeType", "非法的序列化类型[{0}]."}, {"clientExceedsMaxReadIdle", "读IDLE持续时间超过[{0}]s, 关闭客户端连接."}, {"serverExceedsMaxReadIdle", "读IDLE持续时间超过[{0}]s, 关闭服务端连接."}, {"requestProcessorNotFound", "未找到请求类[{0}]的处理器."}, {"ioThreadCannotCallback", "不能由IO线程来回调上层业务, 回调被取消, 请求ID为[{0}]."}, {"ioThreadCannotDoRequest", "不能由IO线程来处理请求，业务请求[ID={0}]被取消[{1}]."}, {"invalidConnectionGrouping", "由归组请求[{0}]计算得到的组名为NULL, 因此断开连接[{1}]."}, {"serverStartSuccess", "服务器成功启动: {0}"}, {"serverStartFail", "服务器启动失败"}, {"serverStopSuccess", "服务器成功关闭: {0}"}, {"server_group_empty", "组[{0}]内没有可用连接."}, {"reconnectThreadStart", "重连线程启动，任务[{0}]."}, {"reconnectThreadExit", "重连线程退出."}, {"reconnectNewTask", "重连任务启动[{0}]."}, {"reconnectTaskRetry", "重试重连任务[{0}]."}, {"reconnectTaskSuccess", "重连任务成功[{0}]."}, {"reconnectTaskCancelled", "重连任务取消[{0}]."}, {"timeoutScanSleepTooLong", "########## 响应超时扫描线程实际睡眠消耗[{0}]ms."}, {"duplicateMsgId", "########## 连续发送多个具有相同ID[{0}]的消息."}, {"incorrectImplRequestProcessor", "########## 错误的RequestProcessor实现，多次创建Executor:[{0}]."}, {"incorrectImplResponseCallback", "########## 错误的ResponseCallback实现，多次创建Executor:[{0}]."}};

    protected Object[][] getContents() {
        return contents;
    }

    public static String getLog(String key, Object... params) {
        try {
            String content = logBundle.getString(key);
            return MessageFormat.format(content, params);
        } catch (Exception e) {
            e.printStackTrace();
            return "没有找到日志资源:" + e.getMessage();
        }
    }
}
